﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="dataimport.aspx.cs" Inherits="Sys_dataimport" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>导入数据</title>
      <link rel="stylesheet" type="text/css" href="../js/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="../js/themes/icon.css"/> 
   	<link rel="stylesheet" type="text/css" href="../CSS/Style.css"/>
    <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script> 
   	<script type="text/javascript" src="../js/jquery.easyui.min.js"></script> 
   	<script type="text/javascript">
   	function checkdata(){
   	 var filePath = document.getElementById("FileUpload1").value;
     var oXL = new ActiveXObject("Excel.Application");
     var oWB = oXL.Workbooks.open(filePath);
     oWB.worksheets(1).select();
     var oSheet = oWB.ActiveSheet;
     var a = oSheet.Rows.Length;
     var b = oSheet.Collumns.Length;
     var str="";
     try{
         for(var i=0;i<b;i++){
             str+=oSheet.Cells(0,i).value;
         }
         alert(str);
     }catch(e){
         alert(e.message);
     }
    document.all.txtArea.value = str;
    oXL.Quit();   
    CollectGarbage();
    return false;
    }
   	</script>  
</head>
<body>
    <form id="form1" runat="server">
     <div style="background:#efefef;width:100%;">
		<a href="announcement.aspx" target="mainwin" class="easyui-linkbutton" plain="true">附件相关</a>&nbsp;&nbsp;|
		<a href="attachedfiles.aspx" target="mainwin" class="easyui-linkbutton" plain="true">系统附件</a>&nbsp;&nbsp;|
		<a href="#" class="easyui-linkbutton" plain="true">数据导入</a>
	</div>	
	<div class="columns_left" style="padding:10px 20px 10px 20px">
        <div class="columns_left_padding">
	       <div class="heading_container">
	             <div class="heading_right_top">&nbsp;</div>
	             <h2>数据导入</h2></div>
	       <div class="bucket_container">
	             <div class="bucket_top"><span>&nbsp;</span>&nbsp;</div>
	             <div class="bucket_content" style="padding:0px;">
                   <div class="bucket_content_undone">
                         <div style="border-bottom: 1px dashed #9FBDE5; margin:0px; padding:5px 10px;">
                           <ul>
                             <li>此导入数据功能允许您将MS_Excel的数据导入到数据库中</li> 
                             <li>在导入前请您按照导入步骤顺序导入，否则无法正确导入</li>
                             <li style="color:Red">请您先将MS_Excel文件中的所有合并单元格去掉并且只留标头与内容显示，否则会导致数据异常</li>
                             <li style="color:Red">目前只支持一个工作单元（sheet）的导入</li>
                             <li style="color:Red">若不存在相应请删除Excel中的相应字段</li>
                             <li>操作流程：选择文件->点击检查->选择导入顺序->开始导入</li>
                           </ul> 
                         </div>
                         <div style="padding:0 20px 20px 20px;" >
                             <table cellpadding="5" cellspacing="5">
                             <tbody>
                             <tr><td><span style="color:#2a5caa">第一步：请选择您的文件（.xls,.xlsx）</span></td><td colspan="3">  <asp:FileUpload ID="FileUpload1" runat="server" />
                                 <asp:Button ID="CheckCollum" 
            runat="server" Text="检查" CssClass="btn-dy-blue" onclick="CheckCollum_Click" OnClientClick="return checkdata()" /></td></tr>
                             <tr><td><span style="color:#2a5caa">第二步：选择数据库中的目标表（目前一个）</span></td><td colspan="3">
                                 <asp:DropDownList ID="DropDownList1" runat="server">
                                     <asp:ListItem Value="Bus_Project">项目</asp:ListItem>
                                 </asp:DropDownList>
                             </td></tr>
                                 <tr>
                                   <td colspan="4"><div runat="server" id="DivOldTitle">您的文件的标头为：</div></td>
                                 </tr>
                                    <tr>
                                   <td colspan="4"><div runat="server" id="DivNewTitle"></div></td>
                                 </tr>
                                <tr><td colspan="4"><span style="color:#2a5caa">第三步：请按照以上Excel中的字段顺序插入顺序（按照您的点击顺序）以便插入数据库中：</span></td></tr> 
                                 <tr>
                                     <td colspan="4">
                                     <div>
                                         <asp:CheckBoxList ID="cblFields" runat="server" RepeatColumns="10" RepeatDirection="Horizontal" RepeatLayout="Flow">
                                             <asp:ListItem Value="type" Selected="True">申报类型</asp:ListItem>
                                             <asp:ListItem Value="pname" Selected="True">项目名称</asp:ListItem>
                                             <asp:ListItem Value="plevel" Selected="True">项目等级</asp:ListItem>
                                             <asp:ListItem Value="ptype" Selected="True">项目类型</asp:ListItem>
                                             <asp:ListItem Value="pway" Selected="True">评审方式</asp:ListItem>
                                             <asp:ListItem Value="pcollege" Selected="True">学院</asp:ListItem>
                                             <asp:ListItem Value="status" Selected="True">状态</asp:ListItem>
                                             <asp:ListItem Value="name" Selected="True">负责人</asp:ListItem>
                                             <asp:ListItem Value="builddate" Selected="True">建设时间</asp:ListItem>
                                             <asp:ListItem Value="approvaldate" Selected="True">立项时间</asp:ListItem>
                                             <asp:ListItem Value="yeardue" Selected="True">年限</asp:ListItem>
                                             <asp:ListItem Value="bz" Selected="True">备注</asp:ListItem>
                                             <asp:ListItem Value="pcode" Selected="True">申报计划编号</asp:ListItem>
                                         </asp:CheckBoxList></div>
                                     </td>
                                 </tr>
                                <tr>
                                    <td align="center" colspan="4">
                                        <asp:Button ID="btnFileOut" runat="server" Text="开始导入" CssClass="btn-dy-blue" OnClick="btnFileOut_Click" />
                                    </td>
                                </tr> 
                             </tbody>
                             </table>
                         </div>
                     </div>
                   </div> 
	           <div class="bucket_bottom"><span>&nbsp;</span>
	           </div>
	   </div>
    </div>
    </div>
    </form>
</body>
</html>

